package LeetDev.a3d;

import javax.microedition.khronos.opengles.GL10;

public class TransparencyContainer implements Comparable<TransparencyContainer> {

	private SubMesh m_subMesh;
	private Matrix m_matrix;
	private float m_zdist;
	private int m_flags;
	
	public int compareTo(final TransparencyContainer tc) throws ClassCastException
	{
		float v=m_zdist-tc.m_zdist;
		if(v<0) {return(-1);}
		else if(v>0) {return(1);}
		return(0);
	}
	
	public TransparencyContainer()
	{
	}
	
	public void set(final SubMesh subMesh, final Matrix matrix, int flags)
	{
		 m_subMesh=subMesh;
		 m_matrix=matrix;
		 m_flags=flags;
		 m_zdist=m_subMesh.calcDist(m_matrix);
	}
	
	public void draw(GL10 gl)
	{
		gl.glLoadMatrixf(m_matrix.m,0);
		if((m_flags&0x1)!=0)
		{
			gl.glEnable(GL10.GL_CULL_FACE);
		}
		else
		{
			gl.glDisable(GL10.GL_CULL_FACE);
		}
		m_subMesh.draw(gl);
	}
}
